///Project: Introducing GLP Paper Table 5 Imputed data
///Stata 13


********TABLE 5*************
clear all 
use "GLP_mi_15 05 31.dta"
count if power==1
count if power==3
count if office1==2
count if office1==7
count if office1==6
count if wealth==0
count if wealth==1
count if region==1
count if region==2
count if region==3
count if region==4
count if region==5
count if regime==0
count if regime==1
/////////Row 1: Age//////////////////
drop if age<20
drop if age>98
/*gen temp=1
sort country_nid 
by country_nid: egen age_persons=total(temp)
gen percent=age_persons/country_num_persons
drop if percent<0.75 */
save "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/GLP_age_15 05 31.dta",replace
//Descriptive
clear all 
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/GLP_age_15 05 31.dta"
count
collapse (mean) aver_age=age, by(country_nid country)
sum aver_age
sort aver_age
//Offices
**Apex**
clear all
use"/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/GLP_age_15 05 31.dta"
keep if power==1
collapse (mean) aver_age=age, by(country_nid country)
sum aver_age
**Top Ten**
clear all
use"/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/GLP_age_15 05 31.dta"
keep if power==3
collapse (mean) aver_age=age, by(country_nid country)
sum aver_age
**Cabinet**
clear all
use"/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/GLP_age_15 05 31.dta"
keep if  office1==2 
collapse (mean) aver_age=age, by(country_nid country)
sum aver_age
**Supreme Court**
clear all
use"/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/GLP_age_15 05 31.dta"
keep if  office1==7 
collapse (mean) aver_age=age, by(country_nid country)
sum aver_age
**MPs**
clear all
use"/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/GLP_age_15 05 31.dta"
keep if  office1==6
collapse (mean) aver_age=age, by(country_nid country)
sum aver_age
//Wealth
**nonoecd**
clear all
use"/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/GLP_age_15 05 31.dta"
keep if wealth==0
collapse (mean) aver_age=age, by(country_nid country)
sum aver_age
count
**oecd**
clear all
use"/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/GLP_age_15 05 31.dta"
keep if wealth==1
collapse (mean) aver_age=age, by(country_nid country)
sum aver_age
//Region
forvalues x=1/5 {
clear all
use"/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/GLP_age_15 05 31.dta"
keep if region==`x'
collapse (mean) aver_age=age, by(country_nid country)
sum aver_age
}
//Regime
**Democracy**
clear all
use"/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/GLP_age_15 05 31.dta"
keep if regime==0
collapse (mean) aver_age=age, by(country_nid country)
sum aver_age
count
**Authoriatarian**
clear all
use"/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/GLP_age_15 05 31.dta"
keep if regime==1
collapse (mean) aver_age=age, by(country_nid country)
sum aver_age
//////////////////////////////////////////////////////////////////////////////////////////////////////
////////Row 2: Male/////////////////
clear all
use "GLP_mi_15 05 31.dta"
sort gender
drop if gender==.
gen male=0
replace male=1 if gender==2 
gen female=0
replace female=1 if gender==1
save  "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/GLP_gender_15 05 31.dta", replace
//Descriptive
clear all
use  "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/GLP_gender_15 05 31.dta"
count
collapse (sum) male=male female=female, by(country country_nid)
gen total=male+female
gen prcmale=male/total*100
gen prcfemale=1-prcmale
sum prcmale
//Offices
**Apex**
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/GLP_gender_15 05 31.dta"
keep if power==1
collapse (sum) male=male female=female, by(country_nid)
gen total=male+female
gen prcmale=male/total*100
sum prcmale
**Top Ten**
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/GLP_gender_15 05 31.dta"
keep if power==3
collapse (sum) male=male female=female, by(country_nid)
gen total=male+female
gen prcmale=male/total*100
sum prcmale
**cabinet**
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/GLP_gender_15 05 31.dta"
keep if office1==2 
collapse (sum) male=male female=female, by(country_nid)
gen total=male+female
gen prcmale=male/total*100
sum prcmale
**Supreme Court**
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/GLP_gender_15 05 31.dta"
keep if office1==7 
collapse (sum) male=male female=female, by(country_nid)
gen total=male+female
gen prcmale=male/total*100
sum prcmale
**MPs**
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/GLP_gender_15 05 31.dta"
keep if office1==6 
collapse (sum) male=male female=female, by(country_nid)
gen total=male+female
gen prcmale=male/total*100
sum prcmale
//Wealth
**nonoecd**
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/GLP_gender_15 05 31.dta"
keep if wealth==0
collapse (sum) male=male female=female, by(country_nid)
gen total=male+female
gen prcmale=male/total*100
sum prcmale
**oecd**
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/GLP_gender_15 05 31.dta"
keep if wealth==1
collapse (sum) male=male female=female, by(country_nid)
gen total=male+female
gen prcmale=male/total*100
sum prcmale
//Region
forvalues x=1/5 {
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/GLP_gender_15 05 31.dta"
keep if region==`x'
collapse (sum) male=male female=female, by(country_nid)
gen total=male+female
gen prcmale=male/total*100
sum prcmale
}
//Regime
**Democracy**
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/GLP_gender_15 05 31.dta"
keep if regime==0
collapse (sum) male=male female=female, by(country_nid)
gen total=male+female
gen prcmale=male/total*100
sum prcmale
**Authoriatarian**
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/GLP_gender_15 05 31.dta"
keep if regime==1
collapse (sum) male=male female=female, by(country_nid)
gen total=male+female
gen prcmale=male/total*100
sum prcmale
/////////////////////////////////////////////////////////////////////////////////////////////////////////
////////Row 3: Married//////////////////
clear all
use "GLP_mi_15 05 31.dta"
drop if marital_status==.
/*gen temp=1
sort country_nid 
by country_nid: egen married_persons=total(temp)
gen percent=married_persons/country_num_persons
drop if percent<0.75*/
gen married=0
replace married=1 if marital_status==2
gen nonmarried=0
replace nonmarried=1 if marital_status==1|marital_status==3|marital_status==4
sort marital_status
save "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/GLP_married_15 05 31.dta", replace
//Descriptive
clear all 
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/GLP_married_15 05 31.dta",
count
sort country_nid 
collapse (sum) married=married nonmarried=nonmarried, by(country country_nid)
gen total=married+nonmarried
gen prcmarried=married/total
sum prcmarried
//Offices
**Apex**
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/GLP_married_15 05 31.dta",
keep if power==1
collapse (sum) married=married nonmarried=nonmarried, by(country_nid)
gen total=married+nonmarried
gen prcmarried=married/total
sum prcmarried
**Top Ten**
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/GLP_married_15 05 31.dta",
keep if power==3
collapse (sum) married=married nonmarried=nonmarried, by(country_nid)
gen total=married+nonmarried
gen prcmarried=married/total
sum prcmarried
**cabinet**
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/GLP_married_15 05 31.dta",
keep if office1==2 
collapse (sum) married=married nonmarried=nonmarried, by(country_nid)
gen total=married+nonmarried
gen prcmarried=married/total
sum prcmarried
**Supreme Court**
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/GLP_married_15 05 31.dta",
keep if office1==7 
collapse (sum) married=married nonmarried=nonmarried, by(country_nid)
gen total=married+nonmarried
gen prcmarried=married/total
sum prcmarried
**MPs**
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/GLP_married_15 05 31.dta",
keep if office1==6 
collapse (sum) married=married nonmarried=nonmarried, by(country_nid)
gen total=married+nonmarried
gen prcmarried=married/total
sum prcmarried
//Wealth
**nonoecd**
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/GLP_married_15 05 31.dta",
keep if wealth==0
collapse (sum) married=married nonmarried=nonmarried, by(country_nid)
gen total=married+nonmarried
gen prcmarried=married/total
sum prcmarried
**oecd**
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/GLP_married_15 05 31.dta",
keep if wealth==1
collapse (sum) married=married nonmarried=nonmarried, by(country_nid)
gen total=married+nonmarried
gen prcmarried=married/total
sum prcmarried
//Region
forvalues x=1/5 {
clear all
use"/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/GLP_married_15 05 31.dta",
keep if region==`x'
collapse (sum) married=married nonmarried=nonmarried, by(country_nid)
gen total=married+nonmarried
gen prcmarried=married/total
sum prcmarried
}
//Regime
**Democracy**
clear all
use"/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/GLP_married_15 05 31.dta",
keep if regime==0
collapse (sum) married=married nonmarried=nonmarried, by(country_nid)
gen total=married+nonmarried
gen prcmarried=married/total
sum prcmarried
**Authoriatarian**
clear all
use"/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/GLP_married_15 05 31.dta",
keep if regime==1
collapse (sum) married=married nonmarried=nonmarried, by(country_nid)
gen total=married+nonmarried
gen prcmarried=married/total
sum prcmarried
/////////////////////////////////////////////////////////////////////////////////////////////////////
////////Row 4: Languages///////////////
clear all
use "GLP_mi_15 05 31.dta"
rename person_lang_all_count langcount
drop if langcount==0
save "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/langcount_mi8.dta",replace

clear all
use  "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/langcount_mi8.dta"
count
sort country_nid
collapse (mean) langcount=langcount, by (country country_nid)
sum langcount
**apex**
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/langcount_mi8.dta" 
keep if power==1
collapse (mean) langcount=langcount, by (country country_nid)
sum langcount
**next 10**
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/langcount_mi8.dta"
keep if power==3
collapse (mean) langcount=langcount, by (country country_nid)
sum langcount
**cabinet**
clear all
use"/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/langcount_mi8.dta"
keep if office1==2
collapse (mean) langcount=langcount, by (country country_nid)
sum langcount
**Supreme court**
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/langcount_mi8.dta"
keep if office1==7
collapse (mean) langcount=langcount, by (country country_nid)
sum langcount
**MPs**
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/langcount_mi8.dta"
keep if office1==6
collapse (mean) langcount=langcount, by (country country_nid)
sum langcount
**Wealth**
*rich*
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/langcount_mi8.dta"
keep if wealth==1
collapse (mean) langcount=langcount, by (country country_nid)
sum langcount
*poor*
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/langcount_mi8.dta"
keep if wealth==0
collapse (mean) langcount=langcount, by (country country_nid)
sum langcount
**regime**
*dem*
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/langcount_mi8.dta"
keep if regime==0
collapse (mean) langcount=langcount, by (country country_nid)
sum langcount
count
*auto*
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/langcount_mi8.dta"
keep if regime==1
collapse (mean) langcount=langcount, by (country country_nid)
sum langcount
count
*regions
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/langcount_mi8.dta"
keep if wealth==0
collapse (mean) langcount=langcount, by (region country_nid)
by region, sort: sum langcount
///////////////////////////////////////////////////////////////////////////////
////////Row 5: Educational Attainment/////////
clear all
use "GLP_mi_15 05 31.dta"
count
tab edulevel
drop if edulevel==0
save "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/dataedu_mi8.dta", replace
count
collapse (mean) edulevel=edulevel, by(country country_nid) //to see number of countries
sum edulevel
**Apex**
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/dataedu_mi8.dta"
keep if power==1
collapse (mean) edulevel =edulevel, by(country country_nid)
sum edulevel
**Top ten**
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/dataedu_mi8.dta"
keep if power==3
collapse (mean) edulevel =edulevel, by(country country_nid)
sum edulevel
**cabinet**
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/dataedu_mi8.dta"
keep if office1==2
collapse (mean) edulevel =edulevel, by(country country_nid)
sum edulevel
**court**
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/dataedu_mi8.dta"
keep if office1==7
collapse (mean) edulevel =edulevel, by(country country_nid)
sum edulevel
**MPs**
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/dataedu_mi8.dta"
keep if office1==6
collapse (mean) edulevel =edulevel, by(country country_nid)
sum edulevel
**Wealth
// nonOECD
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/dataedu_mi8.dta"
keep if wealth==0
collapse (mean) edulevel =edulevel, by(country country_nid)
sum edulevel
// OECD
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/dataedu_mi8.dta"
keep if wealth==1
collapse (mean) edulevel =edulevel, by(country country_nid)
sum edulevel
**Regime**
// Democracy
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/dataedu_mi8.dta"
keep if regime==0
collapse (mean) edulevel =edulevel, by(country country_nid)
sum edulevel
// Autocracy
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/dataedu_mi8.dta"
keep if regime==1
collapse (mean) edulevel =edulevel, by(country country_nid)
sum edulevel
// Regions
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/dataedu_mi8.dta"
collapse (mean) edulevel =edulevel, by(region country_nid)
by region, sort: sum edulevel
//////////////////////////////////////////////////////////////////////////////
////////Row 6: Edu Abroad////////////////
clear all
use "GLP_mi_15 05 31.dta"
drop if person_abroad==.
gen eduabroad=0
replace eduabroad=1 if person_abroad==1
gen eduhome=0
replace eduhome=1 if person_abroad==0
sort country_nid
save "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/eduabroad_mi8.dta", replace
//Descriptive
clear all
use  "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/eduabroad_mi8.dta"
count
collapse (sum) eduabroad=eduabroad eduhome=eduhome, by (country country_nid)
gen total=eduabroad+eduhome
gen prcabroad=eduabroad/total*100
sum prcabroad
//Offices
**Apex**
clear all
use  "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/eduabroad_mi8.dta"
keep if power==1
collapse (sum) eduabroad=eduabroad eduhome=eduhome, by (country country_nid)
gen total=eduabroad+eduhome
gen prcabroad=eduabroad/total*100
sum prcabroad
**Top Ten**
clear all
use  "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/eduabroad_mi8.dta"
keep if power==3
collapse (sum) eduabroad=eduabroad eduhome=eduhome, by (country country_nid)
gen total=eduabroad+eduhome
gen prcabroad=eduabroad/total*100
sum prcabroad
**Cabinet**
clear all 
use  "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/eduabroad_mi8.dta"
keep if office1==2 
collapse (sum) eduabroad=eduabroad eduhome=eduhome, by (country country_nid)
gen total=eduabroad+eduhome
gen prcabroad=eduabroad/total*100
sum prcabroad
**Supreme Court**
clear all 
use  "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/eduabroad_mi8.dta"
keep if office1==7
collapse (sum) eduabroad=eduabroad eduhome=eduhome, by (country country_nid)
gen total=eduabroad+eduhome
gen prcabroad=eduabroad/total*100
sum prcabroad
**MPs**
clear all 
use  "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/eduabroad_mi8.dta"
keep if office1==6 
collapse (sum) eduabroad=eduabroad eduhome=eduhome, by (country country_nid)
gen total=eduabroad+eduhome
gen prcabroad=eduabroad/total*100
sum prcabroad
sort total
**Wealth/Region/Regime**
clear all 
use  "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/eduabroad_mi8.dta"
collapse (sum) eduabroad=eduabroad eduhome=eduhome, by (wealth regime region country_nid)
gen total=eduabroad+eduhome
gen prcabroad=eduabroad/total*100
sum prcabroad
sort country_nid
sum prcabroad if wealth==0
sum prcabroad if wealth==1
sum prcabroad if regime==0
sum prcabroad if regime==1
by region, sort: sum  prcabroad

////////////////////Row 7: Edu in West////////////////
clear all
use "GLP_mi_15 05 31.dta"
sort person_nid 
drop if person_eduwest==.
gen eduwest=0
replace eduwest=1 if person_eduwest==1
gen eduhome=0
replace eduhome=1 if person_eduwest==0
sort country_nid
save "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/eduwest_mi8.dta", replace
//Descriptive
clear all
use  "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/eduwest_mi8.dta"
count
collapse (sum) eduwest=eduwest eduhome=eduhome, by (country country_nid)
gen total=eduwest+eduhome
gen prcwest=eduwest/total*100
sum prcwest
sort prcwest
//Offices
**Apex**
clear all
use  "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/eduwest_mi8.dta"
keep if power==1
collapse (sum) eduwest=eduwest eduhome=eduhome, by (country country_nid)
gen total=eduwest+eduhome
gen prcwest=eduwest/total*100
sum prcwest
**Top Ten**
clear all
use  "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/eduwest_mi8.dta"
keep if power==3
collapse (sum) eduwest=eduwest eduhome=eduhome, by (country country_nid)
gen total=eduwest+eduhome
gen prcwest=eduwest/total*100
sum prcwest
**Cabinet**
clear all 
use  "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/eduwest_mi8.dta"
keep if office1==2 
collapse (sum) eduwest=eduwest eduhome=eduhome, by (country country_nid)
gen total=eduwest+eduhome
gen prcwest=eduwest/total*100
sum prcwest
**Supreme Court**
clear all 
use  "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/eduwest_mi8.dta"
keep if office1==7 
collapse (sum) eduwest=eduwest eduhome=eduhome, by (country country_nid)
gen total=eduwest+eduhome
gen prcwest=eduwest/total*100
sum prcwest
**MPs**
clear all 
use  "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/eduwest_mi8.dta"
keep if office1==6 
collapse (sum) eduwest=eduwest eduhome=eduhome, by (country country_nid)
gen total=eduwest+eduhome
gen prcwest=eduwest/total*100
sum prcwest
**Wealth/Region/Regime**
clear all 
use  "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/eduwest_mi8.dta"
collapse (sum) eduwest=eduwest eduhome=eduhome, by (regime region wealth country_nid)
gen total=eduwest+eduhome
gen prcwest=eduwest/total*100
sort country_nid
sum prcwest if wealth==0
sum prcwest if wealth==1
sum prcwest if regime==0
sum prcwest if regime==1
by region, sort: sum  prcwest
/////////////////////////////////////
///////Row 8: Tenure///////////////////
clear all
use "GLP_mi_15 05 31.dta"
drop if person_office_start_year==0
drop if person_office_start_year>2013
drop if person_office_start_year<1955
gen tenure=2013-person_office_start_year
save "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/datatenure_mi8.dta", replace

clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/datatenure_mi8.dta", clear
count
sort country_nid
collapse (mean) tenure=tenure, by(country country_nid)
sum tenure
**Apex elites
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/datatenure_mi8.dta"
keep if power==1
collapse (mean) tenure=tenure, by(country country_nid)
sum tenure
//Next 10 elites
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/datatenure_mi8.dta"
keep if power==3
collapse (mean) tenure=tenure, by(country country_nid)
sum tenure
**cabinet
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/datatenure_mi8.dta"
keep if office1==2
collapse (mean) tenure=tenure, by(country country_nid)
sum tenure
**Supreme court
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/datatenure_mi8.dta"
keep if office1==7
collapse (mean) tenure=tenure, by(country country_nid)
sum tenure
**MPs
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/datatenure_mi8.dta"
keep if office1==6
collapse (mean) tenure=tenure, by(country country_nid)
sum tenure
**Wealth
*rich
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/datatenure_mi8.dta"
keep if wealth==0
collapse (mean) tenure=tenure, by(country country_nid)
sum tenure
*poor
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/datatenure_mi8.dta"
keep if wealth==1
collapse (mean) tenure=tenure, by(country country_nid)
sum tenure
**Regime
*Demo
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/datatenure_mi8.dta"
keep if regime==0
collapse (mean) tenure=tenure, by(country country_nid)
sum tenure
*auto
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/datatenure_mi8.dta"
keep if regime==1
collapse (mean) tenure=tenure, by(country country_nid)
sum tenure
//regions
clear all
use "/Users/user/Dropbox/GLP/JG_EO_Papers/Introducing GLP Paper/Do-files/imputed_analysis/datatenure_mi8.dta"
collapse (mean) tenure=tenure, by( region country_nid)
by region, sort: sum tenure
